package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlVacation;
import com.ruoyi.sl.service.ISlVacationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 假期基础系数Controller
 * 
 * @author admin
 * @date 2024-06-03
 */
@RestController
@RequestMapping("/sl/vacation")
public class SlVacationController extends BaseController
{
    @Autowired
    private ISlVacationService slVacationService;

    /**
     * 查询假期基础系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:vacation:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlVacation slVacation)
    {
        startPage();
        List<SlVacation> list = slVacationService.selectSlVacationList(slVacation);
        return getDataTable(list);
    }

    /**
     * 导出假期基础系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:vacation:export')")
    @Log(title = "假期基础系数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlVacation slVacation)
    {
        List<SlVacation> list = slVacationService.selectSlVacationList(slVacation);
        ExcelUtil<SlVacation> util = new ExcelUtil<SlVacation>(SlVacation.class);
        util.exportExcel(response, list, "假期基础系数数据");
    }

    /**
     * 获取假期基础系数详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:vacation:query')")
    @GetMapping(value = "/{vacationId}")
    public AjaxResult getInfo(@PathVariable("vacationId") Long vacationId)
    {
        return success(slVacationService.selectSlVacationByVacationId(vacationId));
    }

    /**
     * 新增假期基础系数
     */
    @PreAuthorize("@ss.hasPermi('sl:vacation:add')")
    @Log(title = "假期基础系数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlVacation slVacation)
    {
        slVacation.setCreateBy(getUsername());
        return toAjax(slVacationService.insertSlVacation(slVacation));
    }

    /**
     * 修改假期基础系数
     */
    @PreAuthorize("@ss.hasPermi('sl:vacation:edit')")
    @Log(title = "假期基础系数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlVacation slVacation)
    {
        slVacation.setUpdateBy(getUsername());
        return toAjax(slVacationService.updateSlVacation(slVacation));
    }

    /**
     * 删除假期基础系数
     */
    @PreAuthorize("@ss.hasPermi('sl:vacation:remove')")
    @Log(title = "假期基础系数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vacationIds}")
    public AjaxResult remove(@PathVariable Long[] vacationIds)
    {
        return toAjax(slVacationService.deleteSlVacationByVacationIds(vacationIds));
    }
}
